package com.ruoyi.log;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;

/**
 * @author chenjc
 * @since 2021/03/12 10:12
 */
public class ExceptionClassFilter extends Filter<ILoggingEvent> {

    public static final String MESSAGE = "java.io.IOException: Broken pipe";

    @Override
    public FilterReply decide(ILoggingEvent iLoggingEvent) {
        if (iLoggingEvent.getLevel() == Level.ERROR) {
            if (MESSAGE.equals(iLoggingEvent.getMessage())) {
                return FilterReply.DENY;
            }
            return FilterReply.ACCEPT;
        }
        return FilterReply.DENY;
    }
}
